import axios, {AxiosResponse, InternalAxiosRequestConfig} from 'axios';

const service = axios.create({
    baseURL: import.meta.env.VITE_SERVER_URL,
    timeout: 5000,
    headers:{"Content-Type": "application/json;charset=utf-8"},
})

service.interceptors.request.use((config:InternalAxiosRequestConfig)=>{
    return config;
}, (error) => {
    console.log(error)
    return Promise.reject(error);
})

service.interceptors.response.use((response:AxiosResponse)=>{
    let {code} = response.data
    if(code === '00000'){
        return response.data
    }
}, (error) => {
    return Promise.reject(error.response.data);
})

export default service;